import 'taskConfig.dart';

class TaskRecordBo {
  final int id;
  final String aid;
  final int taskId;
  final double createTime;
  final double updateTime;
  final String status;
  final String subStatus;
  final String? subStatusDesc;
  final double? completeTime;
  final int? contentId;
  final double startDate;
  final double endDate;
  final String? taskContent;
  final TaskConfig? taskConfig;
  final String taskType;
  final int? weight;
  final List<dynamic> taskAuditLogList;
  final List<String>? platformType;
  final String taskName;
  final Map<String, dynamic> frontEndStatus;
  final dynamic latestContentBo;
  final List<dynamic>? taskReportDataBoList;
  final bool? isExpired;

  TaskRecordBo({
    required this.id,
    required this.aid,
    required this.taskId,
    required this.createTime,
    required this.updateTime,
    required this.status,
    required this.subStatus,
    this.subStatusDesc,
    this.completeTime,
    this.contentId,
    required this.startDate,
    required this.endDate,
    this.taskContent,
    this.taskConfig,
    required this.taskType,
    this.weight,
    required this.taskAuditLogList,
    this.platformType,
    required this.taskName,
    required this.frontEndStatus,
    required this.latestContentBo,
    this.taskReportDataBoList,
    this.isExpired,
  });

  factory TaskRecordBo.fromJson(Map<String, dynamic> json) {
    return TaskRecordBo(
      id: json['id'] as int,
      aid: json['aid'] as String,
      taskId: json['taskId'] as int,
      createTime: json['createTime'] != null
          ? (json['createTime'] as num).toDouble()
          : 0.0,
      updateTime: json['updateTime'] != null
          ? (json['updateTime'] as num).toDouble()
          : 0.0,
      status: json['status'] as String,
      subStatus: json['subStatus'] as String,
      subStatusDesc: json['subStatusDesc'] as String?,
      completeTime: json['completeTime'] != null
          ? (json['completeTime'] as num).toDouble()
          : null,
      contentId: json['contentId'] as int?,
      startDate: json['startDate'] != null
          ? (json['startDate'] as num).toDouble()
          : 0.0,
      endDate:
          json['endDate'] != null ? (json['endDate'] as num).toDouble() : 0.0,
      taskContent: json['taskContent'] as String?,
      taskConfig: json['taskConfig'] != null
          ? TaskConfig.fromJson(json['taskConfig'])
          : null,
      taskType: json['taskType'] ?? '',
      weight: json['weight'] as int?,
      taskAuditLogList: List<dynamic>.from(json['taskAuditLogList'] ?? []),
      platformType: json['platformType'] != null
          ? List<String>.from(json['platformType'])
          : null,
      taskName: json['taskName'] ?? '',
      frontEndStatus: Map<String, dynamic>.from(json['frontEndStatus'] ?? {}),
      latestContentBo: json['latestContentBo'],
      taskReportDataBoList: json['taskReportDataBoList'] != null
          ? List<dynamic>.from(json['taskReportDataBoList'])
          : null,
      isExpired: json['isExpired'] as bool?,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'aid': aid,
      'taskId': taskId,
      'createTime': createTime,
      'updateTime': updateTime,
      'status': status,
      'subStatus': subStatus,
      'subStatusDesc': subStatusDesc,
      'completeTime': completeTime,
      'contentId': contentId,
      'startDate': startDate,
      'endDate': endDate,
      'taskContent': taskContent,
      'taskConfig': taskConfig?.toJson(),
      'taskType': taskType,
      'weight': weight,
      'taskAuditLogList': taskAuditLogList,
      'platformType': platformType,
      'taskName': taskName,
      'frontEndStatus': frontEndStatus,
      'latestContentBo': latestContentBo,
      'taskReportDataBoList': taskReportDataBoList,
      'isExpired': isExpired,
    };
  }
}
